package com.mzj.saas.commons;

import java.util.List;
import java.util.Map;

/**
 * @Author: zhanghy
 * @Description: TODO
 * @Date: Create in 19:55 2018/9/5
 * @Version: 1.0
 * @Modificd By:
 */
public class ListFormat {

    public String listMapToString(List<Map<String,Object>> ids){
        if(ids != null && ids.size()>0) {
            String returnSql = "(";
            for (Map<String,Object> map : ids){
                returnSql = returnSql + map.get("id").toString() + ",";
            }
            returnSql = returnSql.substring(0,returnSql.length()-1) + ")";
            return returnSql;
        }
        return "('')";
    }

    public String listLongToString(List<Long> ids){
        if(ids != null && ids.size()>0) {
            String returnSql = "(";
            for (Long id : ids){
                returnSql = returnSql + id + ",";
            }
            returnSql = returnSql.substring(0,returnSql.length()-1) + ")";
            return returnSql;
        }
        return "('')";
    }

    public String listStringToString(List<String> ids){
        if(ids != null && ids.size()>0) {
            String returnSql = "(";
            for (String column : ids){
                returnSql = returnSql + "'" + column + "',";
            }
            returnSql = returnSql.substring(0,returnSql.length()-1) + ")";
            return returnSql;
        }
        return "('')";
    }

}
